<template>

    <h2>登录</h2>
    <table border="1">
        <tr>
            <td>用户名</td>
            <td>
                <input type="text" v-model="Member_Name">
            </td>

        </tr>
        <tr>
            <td>密码</td>
            <td>
                <input type="password" v-model="Member_Pwd">
            </td>
            
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="button" value="登录" @click="login">
            </td>
            
        </tr>
    </table>
</template>
<script setup lang="ts">
import { onMounted,ref,} from "vue";

import axios from 'axios';
import { useRouter,useRoute } from "vue-router";

const Member_Name=ref("");
const Member_Pwd=ref("");
const router=useRouter();

const login=()=>{
    axios.get('https://localhost:7023/api/Member/Login',
    {
        params:{
            Member_Name:Member_Name.value,
            Member_Pwd:Member_Pwd.value
        }
    }
    )
    .then(res=>{
        if(res.data.Member_Id>0){
            alert("登录成功");
            router.push("/AddRoomType");

        }
        else{
            alert("登录失败");
        }
    })
}






</script>